A tiny sample that shows how to view the Open Transport ARP cache.
Introduction
Address Resolution Protocol (ARP) is a protocol for mapping high-level addresses (like the TCP/IP address 17.203.21.205) to low level addresses (like the Ethernet address 08:00:07:EF:49:57). When ARP successfully performs a mapping, it caches the result to avoid having to resend the request. These cached results make up the ARP cache. ARP is required to use TCP/IP over Ethernet networks.
Open Transport TCP/IP has always had an implementation of ARP for its own internal use. The API for accessing OT’s ARP implementation is documented in a DTS sample called, appropriately enough, ARPSample.
This sample shows how you can ask the ARP module to return a report on its ARP cache. The sample does this, and prints the ARP cache to stdout.
Building the Code
This sample was built using the Metrowerks CodeWarrior Pro 1 environment and the Open Transport 1.3 SDK interfaces and libraries.
To rebuild the project, open it in CodeWarrior, change the “LatestInterfaces” and “LatestLibraries” access paths to point to the interfaces and libraries from the OT 1.3 (or newer) SDK, and choose Make from the Project menu.
Caveats
This sample uses the raw streams API provided in "OpenTptClient.h". All the routines in "OpenTptClient.h" can only be called from the native runtime architecture on a machine. As such, this code must be compiled for the classic RTA under 68K and for the PPC RTA on PPC. For more details, see DTS Q&A NW 48 “68K Open Transport Code on Power Macintoshes”:
<http://devworld.apple.com/dev/qa/nw/nw48.html>
Credits and Version History
If you find any problems with this sample, mail <DevSupport@apple.com> with “Attn: Quinn” as the first line of your mail and I’ll try to fix them up.
Version 1.0b1 (Mar 1997) was the first released version.
Version 1.0.1b1 (Mar 1998) is a complete rewrite of the code based on experience from writing another DTS sample, OTDumpInternetStatus. OTDumpInternetStatus is a total superset of DumpARPCache. I’ve revised this sample purely because it answers the specific question of “How do I see the ARP cache?” rather than the generic question of “How do I write netstat for Open Transport?”